﻿using System;
using System.Collections.Generic;
using Microsoft.DirectX .Direct3D ;

namespace WolfGame {

  /// <summary>
  /// This class is used as a common container for textures so that
  /// all used textures are only loaded from disk once and referenced
  /// multiple times.
  /// </summary>
  class v_Textures {

    #region Member Variables

    private Common common;

    #endregion

    #region Constructor

    /// <summary>
    /// Instantiate the class
    /// </summary>
    /// <param name="common"></param>
    public v_Textures(Common common) {
      this.common = common;

      TextureList = new Dictionary<string, Texture>();
    }

    #endregion

    #region Loading

    /// <summary>
    /// Load the texture if it has not already been loaded
    /// </summary>
    /// <param name="name"></param>
    public void LoadTexture(string name) {
      if (!TextureList.ContainsKey(name)) {
        TextureList.Add(name, TextureLoader.FromFile(common.Render.rDevice, String.Format(common.TexturePath,
          System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location),
          name)));
      }
    }

    #endregion

    #region Properties

    public Dictionary<String, Texture> TextureList {get; set;}

    #endregion
  }
}
